<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 创建数组
        var arr = [1, 1, 2, 2, 12, 12, 1, 3, 3, 4, 4, 5];
        for (var i = 0; i < arr.length; i++) {

            // 获取当前元素后的所有元素
            for (var j = i + 1; j < arr.length; j++) {
                //    判断两个元素的值是否相等
                if (arr[i] == arr[j]) {
                    arr.splice(j, 1);
                }
            }
        }
        console.log(arr);
    </script>
</body>

</html>